package com.gpipe.tools;

import com.gpipe.properties.InputProperties;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by admin on 2017/8/24.
 */
public class ODListSum {
    private String date;
    private String timePeriod;
    private String time;
    private String lacCiO;
    private String lacCiD;
    private String commuting;
    private AtomicInteger odSum = new AtomicInteger(0);


    private String s_area_id_o;
    private String m_area_id_o;
    private String b_area_id_o;

    private String s_area_name_o;
    private String m_area_name_o;
    private String b_area_name_o;


    private String s_area_id_d;
    private String m_area_id_d;
    private String b_area_id_d;

    private String s_area_name_d;
    private String m_area_name_d;
    private String b_area_name_d;


    public void init(String date, String timePeriod, String lacCiO, String lacCiD, String commuting) {
        this.time = date + timePeriod.split("-", -1)[1] + "00";
        this.date = date;
        this.timePeriod = timePeriod;
        setLacCiO(lacCiO);
        setLacCiD(lacCiD);
        this.commuting = commuting;
        odSum = new AtomicInteger(1);
    }
    public long getDistance() {
        BaseAreaModel bamO = InputProperties.baseArea.get(lacCiO);
        BaseAreaModel bamD = InputProperties.baseArea.get(lacCiD);
//        try {
        if (bamO!= null && bamD!= null) {
            return Math.round(GpipeInit.getDistance(bamO.getLongitude(), bamO.getLatitude(), bamD.getLongitude(), bamD.getLatitude()));
        } else {
            return -1;
        }
//        } catch (NullPointerException e) {
//            System.out.println();
//        }
//        return Double.valueOf(-1);
    }


    public void setLacCiO(String lacCiO) {
        this.lacCiO = lacCiO;
        BaseAreaModel bam = InputProperties.baseArea.get(lacCiO);
        if (bam != null) {
            this.b_area_id_o = bam.getB_area_id();
            this.m_area_id_o = bam.getM_area_id();
            this.s_area_id_o = bam.getS_area_id();
            this.b_area_name_o = bam.getB_area_name();
            this.m_area_name_o = bam.getM_area_name();
            this.s_area_name_o = bam.getS_area_name();
        }
    }

    public void setLacCiD(String lacCiD) {
        this.lacCiD = lacCiD;
        BaseAreaModel bam = InputProperties.baseArea.get(lacCiD);
        if (bam != null) {
            this.b_area_id_d = bam.getB_area_id();
            this.m_area_id_d = bam.getM_area_id();
            this.s_area_id_d = bam.getS_area_id();
            this.b_area_name_d = bam.getB_area_name();
            this.m_area_name_d = bam.getM_area_name();
            this.s_area_name_d = bam.getS_area_name();
        }
    }

    public String getS_area_id_o() {
        return s_area_id_o;
    }

    public void setS_area_id_o(String s_area_id_o) {
        this.s_area_id_o = s_area_id_o;
    }

    public String getM_area_id_o() {
        return m_area_id_o;
    }

    public void setM_area_id_o(String m_area_id_o) {
        this.m_area_id_o = m_area_id_o;
    }

    public String getB_area_id_o() {
        return b_area_id_o;
    }

    public void setB_area_id_o(String b_area_id_o) {
        this.b_area_id_o = b_area_id_o;
    }

    public String getS_area_name_o() {
        return s_area_name_o;
    }

    public void setS_area_name_o(String s_area_name_o) {
        this.s_area_name_o = s_area_name_o;
    }

    public String getM_area_name_o() {
        return m_area_name_o;
    }

    public void setM_area_name_o(String m_area_name_o) {
        this.m_area_name_o = m_area_name_o;
    }

    public String getB_area_name_o() {
        return b_area_name_o;
    }

    public void setB_area_name_o(String b_area_name_o) {
        this.b_area_name_o = b_area_name_o;
    }

    public String getS_area_id_d() {
        return s_area_id_d;
    }

    public void setS_area_id_d(String s_area_id_d) {
        this.s_area_id_d = s_area_id_d;
    }

    public String getM_area_id_d() {
        return m_area_id_d;
    }

    public void setM_area_id_d(String m_area_id_d) {
        this.m_area_id_d = m_area_id_d;
    }

    public String getB_area_id_d() {
        return b_area_id_d;
    }

    public void setB_area_id_d(String b_area_id_d) {
        this.b_area_id_d = b_area_id_d;
    }

    public String getS_area_name_d() {
        return s_area_name_d;
    }

    public void setS_area_name_d(String s_area_name_d) {
        this.s_area_name_d = s_area_name_d;
    }

    public String getM_area_name_d() {
        return m_area_name_d;
    }

    public void setM_area_name_d(String m_area_name_d) {
        this.m_area_name_d = m_area_name_d;
    }

    public String getB_area_name_d() {
        return b_area_name_d;
    }

    public void setB_area_name_d(String b_area_name_d) {
        this.b_area_name_d = b_area_name_d;
    }

    public String getKey() {
        return lacCiO + "|" + lacCiD + "|" + commuting;
    }

    public AtomicInteger getOdSum() {
        return odSum;
    }

    public void setOdSum(AtomicInteger odSum) {
        this.odSum = odSum;
    }

    public String getCommuting() {
        return commuting;
    }

    public void setCommuting(String commuting) {
        this.commuting = commuting;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getTimePeriod() {
        return timePeriod;
    }

    public void setTimePeriod(String timePeriod) {
        this.timePeriod = timePeriod;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getLacCiO() {
        return lacCiO;
    }


    public String getLacCiD() {
        return lacCiD;
    }

}
